package marchsoft.modules.four.admin.controller;

import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import marchsoft.base.PageVO;
import marchsoft.modules.four.admin.entity.dto.StudyDataDTO;
import marchsoft.modules.four.admin.service.StudyDataService;
import marchsoft.modules.four.common.entity.StudyData;
import marchsoft.response.Result;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@RequestMapping("/api")
@RestController
@RequiredArgsConstructor
public class StudyDataController {
    private final StudyDataService service;

    @ApiOperation("分页条件查询")
    @GetMapping("/eStudyData")
    public Result<Object> selectAllRe(PageVO pageVO, StudyDataDTO studyDataDTO){
        return Result.success(service.queryAll1(pageVO,studyDataDTO));
    }

    @ApiOperation("查询安全分类")
    @GetMapping("/eSafeType/allName")
    public Result<Object> selectAllSafeTypeName( ){
        return Result.success(service.selectAllNameSafeType());
    }

    @ApiOperation("根据id删除学习资料")
    @DeleteMapping("/eStudyData")
    public Result<Object> delete(@RequestBody List<Integer> ids ){
        service.deleteStudyData(ids);
        return Result.success();
    }

    @ApiOperation("新增学习资料")
    @PostMapping("eStudyData")
    public Result<Object> insert(@RequestBody StudyData studyData){
        service.insertStudyData(studyData);
        return Result.success();
    }

    @ApiOperation("更新学习资料")
    @PutMapping("/eStudyData")
    public Result<Object> update(@RequestBody StudyData studyData){
        service.updateStudyData(studyData);
        return Result.success();
    }
}
